package com.shinemo.mpush.alloc.service.chat;

import java.util.HashMap;
import java.util.Map;

import com.mpush.tools.config.CC;
import com.shinemo.mpush.alloc.exception.CommunicationErrorException;
import com.shinemo.mpush.alloc.utils.HttpBodyUtils;
import com.shinemo.mpush.alloc.utils.HttpHeaderUtils;
import com.shinemo.mpush.alloc.utils.HttpUtils;
import com.shinemo.mpush.alloc.vo.MemberListResponse;

/**
 * 会话成员服务
 * 
 * @author gary.zhi
 * @date Aug 21, 2018 9:58:50 PM
 */
public class MemberService {

	public MemberListResponse list(Long sessionId) {

		String url = "http://" + CC.mp.api.server_address + CC.mp.api.memberList;
		
		Map<String,String> requestParams=new HashMap<>(0);
		requestParams.put("sessionId", sessionId.toString());

		MemberListResponse response;
		try {
			response = HttpUtils.post(url, HttpBodyUtils.convert(requestParams), HttpHeaderUtils.get(requestParams), MemberListResponse.class);
		} catch (CommunicationErrorException e) {
			response = new MemberListResponse();
			response.setCode(-1);
			response.setMsg(e.getMessage());
		}

		return response;
	}
}
